{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "93cbcdfc",
   "metadata": {},
   "source": [
    "## 本周学习内容\n",
    "\n",
    "\n",
    "\n",
    "### 一、python环境的配置\n",
    "* A. [github education pack](https://education.github.com/pack)\n",
    ">可验证学生账号，激活邮箱免费使用pycharm\n",
    "\n",
    "\n",
    "* B. [jupyter notebook](https://jupyter.org/)\n",
    "> a.网页交互计算的应用程序，可在网页中直接编写运行代码   \n",
    "> b.安装了anaconda不需要执行pip命令安装   \n",
    "> c.操作的时候不可关闭命令行，否则会断开与本地服务器的连接  \n",
    "\n",
    "\n",
    "* C. [pycharm](https://www.jetbrains.com/pycharm/download/)\n",
    "> a.项目管理类的IDE   \n",
    "> b.下载专业版使用，学生包可获取免费使用一年[github education pack](https://education.github.com/pack)\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ab1a37f9",
   "metadata": {},
   "source": [
    "### 二、项目1：奇数中选择指定时间"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "ba0f4151",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 从python基础库（标准库中）找到 datetime模块\n",
    "from datetime import datetime"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "55d45ba2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.datetime(2021, 9, 25, 14, 28, 2, 536931)"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.today()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "7b750949",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Not an odd minute.\n"
     ]
    }
   ],
   "source": [
    "# 课本代码（项目一，从奇数中选择对应的时间节点）\n",
    "from datetime import datetime\n",
    "odds = [1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59]\n",
    "\n",
    "right_this_minute = datetime.today().minute\n",
    "\n",
    "if right_this_minute in odds: # 冒号引入缩进的代码组\n",
    "    print(\"This minute seems a little odd.\")\n",
    "    \n",
    "else: # 冒号引入缩进的代码组\n",
    "    print(\"Not an odd minute.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "faf89386",
   "metadata": {},
   "source": [
    "### 三、变量"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a946283b",
   "metadata": {},
   "source": [
    "#### 1.变量 用于存储要在计算机程序中引用和操作的信息。"
   ]
  },
  {
   "cell_type": "raw",
   "id": "9f8787a6",
   "metadata": {},
   "source": [
    "number=\"123456\""
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a0b11a8a",
   "metadata": {},
   "source": [
    "上述代码声明了一个变量，变量名为：number，变量name的值为：\"123456\""
   ]
  },
  {
   "cell_type": "markdown",
   "id": "919b1f22",
   "metadata": {},
   "source": [
    "#### 2.变量的类型\n",
    "* int表示整数类型\n",
    "* str表示字符串类型，要有\" \"\n",
    "* float表示小数类型，也就是浮点数\n",
    "* bool表示布尔类型，True或者False"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "966fcc00",
   "metadata": {},
   "source": [
    "#### 3.type函数\n",
    "可以查看变量的类型，语法如下："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "6d51d650",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "str"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "name = \"xiaoma\"\n",
    "type(name)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e2aa8c1c",
   "metadata": {},
   "source": [
    "#### 4.变量的输入\n",
    "获取用户在键盘输入的信息，要用input，用户输入的任何内容python都认为是一个字符串，语法如下："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "926e51c5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入密码123456\n"
     ]
    }
   ],
   "source": [
    "password = input(\"请输入密码\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "48f4d387",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'123456'"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "password"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "4280884e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "123456\n"
     ]
    }
   ],
   "source": [
    "print(password)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b95fcf7d",
   "metadata": {},
   "source": [
    "#### 5.变量的命名\n",
    "* 变量名只能是 字母、数字或下划线的任意组合\n",
    "* 变量名的第一个字符不能是数字\n",
    "* 以下关键字不能声明为变量名 [and, as, assert, break, class, continue, def, del, elif, else, except, exec, finally, for, from, global, if, import, in, is, lambda,not, or, pass, print, raise, return, try, while, with, yield]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5a63304d",
   "metadata": {},
   "source": [
    "### 四、if else条件判断\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2cd79139",
   "metadata": {},
   "source": [
    "#### 1.语法如下："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "92227d12",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Not an odd minute.\n"
     ]
    }
   ],
   "source": [
    "from datetime import datetime\n",
    "\n",
    "odds = [  1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59]\n",
    "\n",
    "right_this_minute = datetime.today().minute\n",
    "\n",
    "if right_this_minute in odds:\n",
    "    print(\"This minute seems a little odd.\")\n",
    "else:\n",
    "    print(\"Not an odd minute.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cc536f7c",
   "metadata": {},
   "source": [
    "* 注意：可以进行嵌套。 不要超过3层， 最多5层"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "43bea06d",
   "metadata": {},
   "source": [
    "#### 2.if elif else 的运用"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "b09d98a8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "party!!\n"
     ]
    }
   ],
   "source": [
    "import time\n",
    "\n",
    "today = time.strftime(\"%A\")\n",
    "\n",
    "if today == 'Saturday':  #if-语句块\n",
    "    print('party!!')\n",
    "elif today == 'Sunday':  #elif-语句块\n",
    "    print('recover.')\n",
    "else:                    #else-语句块\n",
    "    print('study,study,study.')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5ea666d4",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
